﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LibrarySystem
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int _aid = Convert.ToInt32(Request.QueryString["aid"]);
                BusinessLayer.Author author = BusinessLayer.Author.getByAid(_aid);
                List<BusinessLayer.Book> books = BusinessLayer.Book.getByAuthor(_aid);

                if (author != null)
                {
                    authorDetailName.Text = author.FirstName + " " + author.LastName;
                    authorDetailYear.Text = (author.BirthYear == 0) ? "" : "(" + author.BirthYear.ToString() + ")";
                }

                if (books.Count != 0)
                {
                    authorDetailCount.Text = "Antal böcker: " + books.Count;
                    bookDetailCopyList.DataSource = books;
                    bookDetailCopyList.DataBind();
                }

        }
        protected void listItem_ClickedBook(object sender, CommandEventArgs e)
        {
            string itemISBN = e.CommandName.ToString();
            Response.Redirect("bookDetailPage.aspx?isbn=" + itemISBN);
        }

    }
}